package org.example.common;

/**
 * 通用的数据工具类
 */
public class DataResults {

    private int code; //状态码
    private String msg; //响应消息
    private Object data; //响应体

    public DataResults() {
    }

    public DataResults(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static DataResults success(Object data) {
        return new DataResults(200, "success", data);
    }

    public static DataResults success() {
        return new DataResults(200, "success", null);
    }

    public static DataResults fail(String msg) {
        return new DataResults(500, msg, null);
    }
}
